package com.pine.dao.pineframework.constants;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.pine.common.beans.enums.IntegerCodeBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * <p>
 * 申请/审批状态- 枚举<br>
 * <li> 待提交：审批流程尚未开始，等待发起人提交审批请求</li>
 * <li> 待审批：审批流程已开始，等待审批人审批</li>
 * <li> 已审批：审批人已审批</li>
 * <li> 已拒绝：审批人已拒绝</li>
 * <li> 已完成：审批人已审批，且审批流程已结束（数据归档）</li>
 * <li> 已取消：发起人取消审批流程</li>
 * </p>
 *
 * @author pine manage
 * @since 2024-10-31
 */
@AllArgsConstructor
@Getter
public enum ApprovalStatusEnum implements IntegerCodeBaseEnum {

    WAIT_SUBMIT(0, "待提交"),
    WAIT_APPROVAL(1, "待审批"),
    APPROVED(2, "已审批"),
    REFUSED(3, "已拒绝"),
    FINISHED(4, "已完成"),
    CANCELLED(5, "已取消");

    @EnumValue
    private final Integer code;
    private final String desc;

    public static ApprovalStatusEnum of(Integer code) {
        return Arrays.stream(ApprovalStatusEnum.values()).filter(approvalStatusEnum -> Objects.equals(approvalStatusEnum.code, code)).findAny().orElse(null);
    }
}
